<?php
header("Pragma: public");
header("Expires: 0");
header("Accept-Ranges: bytes");
header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
header("Content-Type: application/vnd.ms-excel");
header('Content-Disposition: attachment; filename=facultetjournal-'.date("Y-m-d").'.xls');
header("Content-Transfer-Encoding: binary");
?>
<?php
 // debug($facultets_total);
?>

<h2><?php __('Список абитуриентов подготовленных для рейтинга по факультетам ');?></h2>
<?php 
	foreach ($facultets_total as $facultet_total):

?>
<h3><?php 
	if ($facultet_total && $facultet_total[0] && $facultet_total[0]['facultet_id']) {
		echo $facultetslist[$facultet_total[0]['facultet_id']];
	}
	?> 
</h3>
<table cellpadding="1" cellspacing="1" border="1" bordercolor="000">
<tr>
	<th>№</th>
	<th>ID</th>
	<th>ФИО</th>
	<th>Специальность</th>
	<th>Тип обучения</th>
	<th>Форма обучения</th>
</tr>
<?php 
	$i=1;
	foreach ($facultet_total as $element):
		foreach ($element['abiturients'] as $abiturient):
		echo '<tr>';
			echo '	<td>';
			echo $i;
			echo '	</td>';
			echo '	<td>';
			echo $abiturient['Abiturient']['id'];
			echo '	</td>';
			echo '	<td>';
			echo $abiturient['Abiturient']['lastname'].' ';  
			echo $abiturient['Abiturient']['firstname'].' ';  
			echo $abiturient['Abiturient']['surname']; 
			echo '	</td>';
			echo '	<td>';
			echo $professions[$element['profession_id']];
			echo '	</td>';	
			echo '	<td>';
			echo $learningforms[$element['learningform_id']];
			echo '	</td>';
			echo '	<td>';
			echo $learningtypes[$element['learningtype_id']];
			echo '	</td>';	
			echo '</tr>';
			$i++;
		endforeach;	
	endforeach;
?>
</table>
<?php 
 endforeach;
?>